<template>
  <div class="flow-bar">
    <div class="flow-bar-left">
      <span class="left-text"></span>
    </div>
    <div class="flow-bar-right">
      <a-space :size="8">
        <a-button type="link" danger @click="onCloseFlow"> 关闭流程 </a-button>
        <a-button type="primary" @click="onSave"> 保存 </a-button>
      </a-space>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';
import { useStore } from 'vuex';
import { message, Modal } from 'ant-design-vue';
import eventBus from '@/core/eventBus';
import { ResponseHandle } from '@/global/util/preUtils';

export default defineComponent({
  name: 'FlowBar',
  setup() {
    const store = useStore();
    const onCloseFlow = () => {
      Modal.confirm({
        title: '确定关闭?',
        content: '确定关闭流程吗，请确认!',
        async onOk() {
          store.dispatch('flowDesign/closeFlow');
        },
      });
    };
    const onSave = async () => {
      eventBus.emit('flow-design-save');
      const res = await store.dispatch('flowDesign/saveFlow');
      ResponseHandle(res, () => message.success('保存成功'));
    };

    return {
      onCloseFlow,
      onSave,
    };
  },
});
</script>

<style lang="less" scoped>
.flow-bar {
  .flexRow(space-between);
  padding: 0 32px;
  height: 40px;
  line-height: 40px;
  background-color: @rb-body-background;
  color: @rb-text-color-light;
  z-index: 2;
  &-left {
    .left-text {
    }
  }
  &-right {
  }
}
</style>
